<template>
  <view class="reservationPage">
    <view class="head" :style="[{ height: customBar + 'px' }]">
      <u-navbar
        title="预约记录"
        :autoBack="true"
        :titleStyle="{ fontSize: '34rpx', fontWeight: '500' }">
        <view slot="left"></view>
      </u-navbar>
    </view>
    <view class="tab">
      <u-tabs
        :list="list1"
        @click="handleTab"
        scrollable="false"
        lineWidth="25"
        :current="current"
        lineColor="#A3C51A"
        :activeStyle="{
          color: '#000000',
          fontWeight: '600',
          transform: 'scale(1.05)',
        }"
        :inactiveStyle="{
          color: '#000000',
          fontWeight: '400',
          transform: 'scale(1)',
        }"
        itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;"></u-tabs>
    </view>
    <!-- 列表 -->
    <view class="reservationBox" v-if="current == 0">
      <view class="reservationList" @click="handleDetail">
        <view class="reservationLeft">
          <image class="img" src="@/static/reservation/leftImg.png"></image>
        </view>
        <view class="reservationRight">
          <view class="reservationName">千羽名仕健身馆</view>
          <view class="reservationLable">
            <view class="label_green">羽毛球</view>
            <view class="label_green">网球</view>
            <view class="label_green">网球</view>
          </view>
        </view>
        <view class="voucherBox">
          <view class="reservationVoucher" @click="goReservation">预约</view>
        </view>
      </view>
    </view>
    <view class="reservationDetail" v-if="current == 1">
      <view class="tabList">
        <view
          v-for="(item, index) in tabList"
          :key="index"
          :class="tabIndex == index ? 'active' : 'myCourse'"
          @tap="handleAll(index)">
          <view class="myCourseRight">
            {{ item }}
          </view>
        </view>
      </view>
      <view class="recordList">
        <view class="tip tipused">
          <view class="name">待使用</view>
        </view>
        <view class="recordTop">
          <image
            class="img"
            src="@/static/reservation/recordSp.png"
            mode="widthFix"></image>
          千羽名仕健身馆
        </view>
        <view class="recordBottom">
          <view class="recordLeft">
            <image class="img" src="@/static/reservation/leftImg.png"></image>
          </view>
          <view class="recordRight">
            <view class="recordLine">
              预定时间：
              <view class="recordTime">10:00～12:00</view>
            </view>
            <view class="recordLine">
              预订场地：
              <view class="recordTime">1号场地</view>
            </view>
            <view class="recordLine">￥399.00</view>
          </view>
          <view class="cancel" @click="handleCancel">取消预约</view>
        </view>
      </view>
      <!-- 3333 -->
      <view class="recordList">
        <view class="tip tipsuccess">
          <view class="name">已完成</view>
        </view>
        <view class="recordTop">
          <image
            class="img"
            src="@/static/reservation/recordSp.png"
            mode="widthFix"></image>
          千羽名仕健身馆
        </view>
        <view class="recordBottom">
          <view class="recordLeft">
            <image class="img" src="@/static/reservation/leftImg.png"></image>
          </view>
          <view class="recordRight">
            <view class="recordLine">
              预定时间：
              <view class="recordTime">10:00～12:00</view>
            </view>
            <view class="recordLine">
              预订场地：
              <view class="recordTime">1号场地</view>
            </view>
            <view class="recordLine">￥399.00</view>
          </view>
          <view class="cancel">取消预约</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      customBar: 88,
      current: 0,
      tabIndex: 0,
      list1: [
        {
          name: "场馆列表",
        },
        {
          name: "场馆预约记录",
        },
      ],
      tabList: ["全部", "待使用", "已完成"],
    };
  },

  computed: mapGetters(["isLogin", "uid", "userInfo"]),
  onLoad() {},
  methods: {
    handleTab(obj) {
      this.current = obj.index;
    },
    handleAll(index) {
      this.tabIndex = index;
    },
    handleDetail() {
      uni.navigateTo({
        url: "/pages/reservation/venueDetails",
      });
    },
    goReservation() {
      uni.navigateTo({
        url: "/pages/reservation/reserve",
      });
    },
    handleCancel(item) {
     uni.navigateTo({
       url: "/pages/reservation/cancelOrder?data=" + JSON.stringify(item),
     });
    },
  },
};
</script>

<style lang="scss">
.reservationPage {
  height: 100%;
  min-height: 100vh;
  font-family: PingFang SC;
  background: #f5f5f4;
  // padding-bottom: calc(env(safe-area-inset-bottom) / 2);
  .head {
    background: #fff;
  }
  .tab {
    background: #fff;
    height: 90rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
    ::v-deep .u-tabs {
      width: 60%;
    }
  }

  ::v-deep .u-tabs__wrapper__nav {
    display: flex;
    flex-direction: row;
    position: relative;
    justify-content: space-between;
  }
  ::v-deep .u-tabs__wrapper__nav__item__text {
    flex: 1 !important;
  }
  .reservationBox {
    padding: 0 30rpx;
    margin-top: 20rpx;
    .reservationList {
      width: 100%;
      background: #ffffff;
      box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0, 0, 0, 0.1),
        inset 0rpx 2rpx 2rpx 0rpx #ffffff;
      border-radius: 28rpx;
      margin-bottom: 20rpx;
      display: flex;
      padding: 20rpx 22rpx;
      box-sizing: border-box;
      .reservationLeft {
        width: 156rpx;
        height: 156rpx;
        background: #ffffff;
        border-radius: 28rpx;
        .img {
          width: 156rpx;
		  height: 156rpx;
        }
      }
      .reservationRight {
        margin-left: 20rpx;
        display: flex;
        width: 100%;
        flex-wrap: wrap;
        .reservationName {
          font-weight: 500;
          font-size: 32rpx;
        }
        .reservationLable {
          display: flex;
          margin-top: 64rpx;
          flex-wrap: wrap;

          .label_green {
            padding: 5rpx 20rpx;
            color: #a3c616;
            background: rgba(163, 198, 22, 0.2);
            border-radius: 40rpx;
            font-size: 24rpx;
            margin-right: 10rpx;
            margin-top: 10rpx;
          }
        }
      }
      .voucherBox {
        display: flex;
        align-items: center;
      }
      .reservationVoucher {
        width: 112rpx;
        height: 56rpx;
        background: linear-gradient(90deg, #c1ed1f 0%, #a3c616 100%);
        box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(162, 198, 22, 0.3);
        border-radius: 44rpx;
        font-family: PingFangSC, PingFang SC;
        font-weight: 500;
        font-size: 28rpx;
        color: #ffffff;
        line-height: 56rpx;
        text-align: center;
        font-style: normal;
        flex-shrink: 0;
      }
    }
  }
  .reservationDetail {
    padding: 0 30rpx;
  }
  .tabList {
    display: flex;
    margin-top: 20rpx;
    justify-content: space-around;
  }
  .myCourse {
    width: 216rpx;
    height: 88rpx;
    line-height: 88rpx;
    background: #ffffff;
    box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(0, 0, 0, 0.1);
    border-radius: 200rpx;
    text-align: center;
  }
  .active {
    width: 216rpx;
    height: 88rpx;
    border-radius: 200rpx;
    line-height: 88rpx;
    background: #a3c616;
    color: #ffffff;
    text-align: center;
  }
  .recordList {
    width: 100%;
    background: #ffffff;
    box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0, 0, 0, 0.1),
      inset 0rpx 2rpx 2rpx 0rpx #ffffff;
    border-radius: 28rpx;
    margin-top: 20rpx;
    // display: flex;
    padding: 20rpx 22rpx;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
    .recordTop {
      display: flex;
      align-items: center;
      .img {
        width: 34rpx;
        margin-right: 10rpx;
      }
    }
    .tip {
      position: absolute;
      height: 108rpx;
      width: 108rpx;
      right: -51rpx;
      top: -53rpx;
      -webkit-transform: rotate(45deg);
      transform: rotate(45deg);
      font-size: 20rpx;
      .name {
        top: 76rpx;
        left: 29rpx;
        color: #fff;
        position: relative;
      }
    }
    .tipused {
      background: #a3c616;
    }
    .tipsuccess {
      background: #e5e5e5;
    }
  }
  .recordBottom {
    margin-top: 12rpx;
    display: flex;
    .recordLeft {
      width: 136rpx;
      height: 136rpx;
      background: #ffffff;
      border-radius: 28rpx;
      .img {
        width: 136rpx;
		height: 136rpx;
      }
    }
    .recordRight {
      margin-left: 12rpx;
      .recordLine {
        display: flex;
        font-size: 26rpx;
        color: #6d7278;
        margin-top: 12rpx;
      }
      .recordTime {
        color: #a3c616;
      }
    }
    .cancel {
      width: 172rpx;
      height: 56rpx;
      background: #fbffed;
      border-radius: 44rpx;
      border: 1rpx solid #a3c616;
      font-family: PingFangSC, PingFang SC;
      font-weight: 500;
      font-size: 28rpx;
      color: #a3c616;
      line-height: 56rpx;
      text-align: center;
      margin-left: 22rpx;
      margin-top: 80rpx;
    }
  }
}
</style>
